//
//  CreateJobSuccessVC.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/3/31.
//

import UIKit

class CreateJobSuccessVC: BaseViewController {
    var model: PVDDetailModel!
    override func viewDidLoad() {
        super.viewDidLoad()
        let customView = CreateJobSuccessView()
        customView.setData(self.model == nil ? "" : self.model.gwt_id)
        self.view = customView
        customView.okBtn.addTarget(self, action: #selector(okBtnClick), for: UIControl.Event.touchUpInside)
        
    }
    @objc func okBtnClick(){
        guard let navi = self.navigationController else {return}
        guard let _ = self.model else { return  }
        if self.model.isInstallerFlag || self.model.isDesignerFlag{//有权限查看job detail
            if navi.viewControllers.count > 0{
                var controllers: [UIViewController] = [navi.viewControllers[0]]
                JobDetailModelHelper.shared.jobDetailModel.pvd_id = self.model.pvd_id
                SentryHelper().setCrashLogCustomInfo(pvdId: self.model.pvd_id ,gwtNo: self.model.gwt_id)
                JobDetailModelHelper.shared.jobDetailModel = self.model
                let vc = JobDetailViewController()
                vc.hidesBottomBarWhenPushed = true
                controllers.append(vc)
                navi.setViewControllers(controllers, animated: true)

            }
        }else{
            navi.popViewController(animated: true)
        }
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(true, animated: false)
    }
}
